﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using fcwms.Common;

public partial class admin_chuku_clear_edit : SessionManage
{
    private string action = ActionEnum.Add.ToString(); //操作类型
    private int id = 0;
    protected fcwms.Model.dt_ruku model = new fcwms.Model.dt_ruku();
    protected void Page_Load(object sender, EventArgs e)
    {
        string _action = DTRequest.GetQueryString("action");
        if (!string.IsNullOrEmpty(_action) && _action == ActionEnum.Edit.ToString())
        {
            this.action = ActionEnum.Edit.ToString();//修改类型
            if (!int.TryParse(Request.QueryString["id"] as string, out this.id))
            {
                MessageBox.Jscript(this, "传输参数不正确！", "back", "Error");
                return;
            }
            if (!new fcwms.BLL.dt_ruku().Exists(this.id))
            {
                MessageBox.Jscript(this, "信息不存在或已被删除！", "back", "Error");
                return;
            }
        }
        if (!IsPostBack)
        {
            //    string user_id = Session["username"].ToString();
            //    txtTransactor.Text = new fcwms.BLL.dt_users().GetTitle(user_id);

            //    txtRukuTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
            //    RukuWayBind();
            //    RukuStorageBind();
            //    if (action == ActionEnum.Edit.ToString())
            //    {
            //        ShowInfo(this.decla_id);
            //    }
            RptBind();
        }
    }
    #region 组合数据绑定==========================
    public void RptBind()
    {
        int id = this.id;
        StringBuilder strSql2 = new StringBuilder();
        strSql2.Append("select top 1 decla_id from dt_ruku ");
        strSql2.Append("where id=@id");
        SqlParameter[] parms2 = new SqlParameter[] { 
                new SqlParameter("@id",id)};
        string decla_id = DbHelperSQL.GetSingle(strSql2.ToString(),parms2).ToString();

        model = new fcwms.BLL.dt_ruku().GetModel(decla_id);

        StringBuilder strSql = new StringBuilder();
        strSql.Append("select * ");
        strSql.Append(" FROM dt_goods where decla_id=@decla_id  ");
        SqlParameter[] parms = new SqlParameter[]{
                new SqlParameter("@decla_id",decla_id)};

        DataSet ds = DbHelperSQL.Query(strSql.ToString(),parms);
        rptList.DataSource = ds.Tables[0].DefaultView;
        rptList.DataBind();
    }
    #endregion
}